#include "string.h"

namespace mihayou
{
	void test01()
	{
		string s1 = "hello world";
		cout << s1.c_str() << endl;
		string s2;
		cout << s2.c_str() << endl;

		cout << s1[1] << endl;
		s2 = s1;
		cout << s2.c_str() << endl;

		string s3 = "123456789aaaaab";
		s3.push_back('k');
		cout << s3.c_str() << endl;

		for (auto e : s3)
		{
			cout << e;
		}
		cout << endl;
		string::iterator it = s3.begin();
		while (it != s3.end())
		{
			cout << *it;
			it++;
		}
		cout << endl;
	}

	void test02()
	{
		string s1 = "hello world";
		s1 += 'k';
		cout << s1.c_str() << endl;

		for (size_t i = 0; i < s1.size(); i++)
		{
			s1[i] += 2;
		}
		cout << s1.c_str() << endl;

		string s2 = "hello world";
		s2.append(" mi ha youp1111111111111");
		s2 += " mi ha youp1111111111111";
		cout << s2.c_str() << endl;

		string s3 = "hello world";
		s3.insert(s3.size(), 'k');
		s3.insert(5, 'k');
		s3.insert(0, 'k');
		cout << s3.c_str() << endl;

		string s4 = "hello world";
		s4.insert(s4.size(), "hhh");
		cout << s4.c_str() << endl;

		s4.insert(0, "hhhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
		cout << s4.c_str() << endl;

		s4.insert(5, "hhh");
		cout << s4.c_str() << endl;
	}

	void test03()
	{
		string s1 = "hello world";
		s1.erase(6);
		cout << s1.c_str() << endl;

		string s2 = "hello world";
		s2.erase(6, 1000);
		cout << s2.c_str() << endl;

		string s3 = "hello world";
		s3.erase(6, 3);
		cout << s3.c_str() << endl;

		string s4 = "hello world";
		cout << s4.find('w',2) << endl;

		string s5 = "hello world";
		cout << s5.find("llo",1) << endl;
	}

	void test04()
	{
		string s1 = "hello world";
		size_t pos = s1.find("ll");
		string s2 = s1.substr(pos,5);
		cout << s2.c_str() << endl;
		
		string k(s1);
		cout << k.c_str() << endl;

		string s3 = s1;
		cout << s3.c_str() << endl;

		s3 = s3;
		cout << s3.c_str() << endl;
	}

	void test05()
	{
		string s1 = "hello world";
		string s2 = "hello world";
		cout << (s1 < s2) << endl;
		cout << (s1 <= s2) << endl;
		cout << (s1 > s2) << endl;
		cout << (s1 >= s2) << endl;
		cout << (s1 == s2) << endl;
		cout << (s1 != s2) << endl;

		cout << ("hello world" == s1) << endl;

	}

	void test06()
	{
		string s1 = "hello world";
		cin >> s1;
		cout << s1 << endl;
	}
}

int main()
{
	mihayou::test01();
	//mihayou::test02();
	//mihayou::test03();
	//mihayou::test04();
	//mihayou::test05();
	//mihayou::test06();
	return 0;
}